#include "DoubleLinkedList.h"

template <typename DT>
typename DoubleLinkedList<DT>::iterator find(const DoubleLinkedList<DT> &_list, const DT &_val);

int main(int argc, char const *argv[])
{
    DoubleLinkedList<int> L;
    L.printList();
    for (int i = 1; i <= 5; i++)
        L.push_back(i);
    L.printList();
    auto iter = find(L, 3);
    L.erase(iter);
    L.printList();
    iter = find(L, 3);
}

template <typename DT>
typename DoubleLinkedList<DT>::iterator find(const DoubleLinkedList<DT> &_list, const DT &_val)
{
    if (!_list.empty())
        for (auto itr = _list.begin(); itr != _list.end(); itr++)
            if (*itr == _val)
                return itr;
    std::cerr << "Error: Not found." << std::endl;
    return _list.begin();
}
